/**
 * 
 */
package com.geezdata.cps.ttk.domain.factory;

import java.util.Date;

import com.geezdata.cps.ttk.common.enums.JobTypeEnum;
import com.geezdata.cps.ttk.common.vo.JobVO;
import com.geezdata.cps.ttk.domain.domain.Job;

/**
 * @author sszheng
 * @date 创建时间：2017年10月19日 下午2:19:26
 *
 */
public class JobFactory {
	public static Job newInstance(JobVO jobVO) {
		Date now = new Date();
		Job job = new Job();
		JobTypeEnum jobTypeEnum = JobTypeEnum.getByCode(jobVO.getJobTypeCode());
		job.setEndTime(jobVO.getSendModeVO().getEndTime());
		job.setExecutionCycle(jobVO.getSendModeVO().getExecutionCycle());
		job.setExecutionCycleUnit(jobVO.getSendModeVO().getExecutionCycleUnit());
		job.setJobGroup(String.valueOf(jobVO.getMerchantId()));
		job.setJobName(jobVO.getJobDesc());
		job.setParams(jobVO.getParams());
		job.setSendType(jobVO.getSendModeVO().getSendType());
		job.setStartTime(jobVO.getSendModeVO().getStartTime());
		job.setTriggerGroup(String.valueOf(jobVO.getMerchantId()));
		job.setTriggerName(jobTypeEnum.getTriggerName(jobVO.getJobDesc()));
		job.setClassName(jobTypeEnum.getJobClassName());
		job.setCallbackUrl(jobVO.getCallbackUrl());
		job.setCreatedAt(now);
		job.setUpdatedAt(now);
		job.setStatus(0);
		return job;
	}
}
